﻿using Microsoft.CSharp.Activities;
using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Creates a new list for the authenticated user. 
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.ListToolbox.bmp")]
    [Designer(typeof(ListDesigner))]
    [Description("Creates a new list for the authenticated user.")]
    public class CreateList : TwitterOperationInvoker<List>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateList"/> class.
        /// </summary>
        public CreateList()
            : base("CreateList")
        {
            Mode = new InArgument<string>(new CSharpValue<string>("\"public\""));
        }


        /// <summary>
        /// The name for the list.
        /// <remarks>
        /// Required Argument
        /// </remarks>
        /// </summary>
        /// <value>
        /// The name.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [Description("The name for the list.")]
        [RequiredArgument]
        public InArgument<string> Name { get; set; }

        /// <summary>
        /// Whether your list is public or private. Values can be public or private.
        /// <remarks>
        /// Required Argument
        /// </remarks>
        /// </summary>
        /// <value>
        /// The mode.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [Description("Whether your list is public or private. Values can be public or private.")]
        [RequiredArgument]
        public InArgument<string> Mode { get; set; }

        /// <summary>
        /// The description to give the list.
        /// </summary>
        /// <value>
        /// The description.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [Description("The description to give the list.")]
        public InArgument<string> Description { get; set; }


        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
        {
            RuntimeArgument nameArgument = new RuntimeArgument("Name", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(Name, nameArgument);
            metadata.AddArgument(nameArgument);

            RuntimeArgument modeArgument = new RuntimeArgument("Mode", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(Mode, modeArgument);
            metadata.AddArgument(modeArgument);

            RuntimeArgument descriptionArgument = new RuntimeArgument("Description", typeof(string), ArgumentDirection.In, false);
            metadata.Bind(Description, descriptionArgument);
            metadata.AddArgument(descriptionArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("name", Name);
            Parameters.Add("mode", Mode);
            Parameters.Add("description", Description);

            base.Execute(context);
        }
    }
}
